<?php
/**
*+------------------APP 收藏控制器-----------------+
*--------------------------------------------------+
*+-----------用户收藏（取消收藏)视频，比赛---------+
*+-----------用户收藏信息的获取--------------------+
*+-------------------------------------------------+
*+-@author susy.liang <liangling@ilongyuan.com.cn>-+
*+-------------------------------------------------+
*/

namespace Api\Controller;

class FavourController extends UserBaseController 
{	

	/**
	*开放操作，非登录下
	*/
	static $openAction = array('get');

	/**
	*事件对象
	*/
	protected $eventObj = '';

	/**
	*参数初始化
	*@author susy.liang <liangling@ilongyuan.com.cn>
	*/
	protected function _initialize(){

		parent::_initialize();
		$this->eventObj = A('Api/Favour', 'Event');
	}

	/**
	*用户添加收藏
	*@author susy.liang <liangling@ilongyuan.com.cn>
	*/
	public function add(){

		$id = I('id', 0, 'intval');
		$res = $this->eventObj->add(UID, $id);

		if($res['code'] == self::$API_ERROR['SUCCESS'])
			$this->success($res['info']);
		else
			$this->error($res['code'], $res['info']);

	}


	/**
	*用户取消收藏
	*@author susy.liang <liangling@ilongyuan.com.cn>
	*/
	public function undo(){

		$id = I('id', 0, 'intval');
		$res = $this->eventObj->undo(UID, $id);

		if($res['code'] == self::$API_ERROR['SUCCESS'])
			$this->success($res['info']);
		else
			$this->error($res['code'], $res['info']);

	}
}
